import { ref, h } from 'vue';
import AddEnum from './AddEnum.vue';

export default () => {
    // 字段配置
    const formConfig = ref([
        {
            tag: 'n-input',
            label: '名称',
            code: 'name',
            value: '',
            nullValue: '',
            visible: true,
            comStyle: {},
            comProps: {
                type: 'text',
                placeholder: '请输入名称'
            }
        },
        {
            tag: 'n-input',
            label: '编码',
            code: 'code',
            value: '',
            nullValue: '',
            visible: true,
            comStyle: {},
            comProps: {
                type: 'text',
                placeholder: '请输入编码'
            }
        },
        {
            tag: 'n-input',
            label: '枚举值',
            code: 'options',
            value: [],
            nullValue: [],
            visible: true,
            comProps: {},
            render(item) {
                return h(AddEnum, { data: item });
            }
        }
    ]);
    // 校验配置
    const formRules = ref({
        name: [
            {
                required: true,
                message: '名称不能为空',
                trigger: 'blur'
            }
        ],
        code: [
            {
                required: true,
                message: '编码不能为空',
                trigger: 'blur'
            }
        ]
    });
    return {
        formConfig,
        formRules
    };
};
